import java.awt.event.*;

public class KeyListenerTester implements KeyListener {

    public void keyPressed(KeyEvent e) {

        int c = e.getKeyCode();
        /*
         * System.out.println("id: "+id);
         * System.out.println("e.getKeyChar(): "+e.getKeyChar()+"c: "+c);
         * System.out.println();
         * 
         * System.out.println("KeyEvent.KEY_TYPED: "+KeyEvent.KEY_TYPED);
         * System.out.println("e.getKeyCode(): "+e.getKeyCode());
         * System.out.println("e.isActionKey(): "+e.isActionKey());
         */

        if (c == KeyEvent.VK_P) {

            if (game.myTimer.isRunning()) {
                game.myTimer.stop();
            } else
                game.myTimer.start();

        }
        if (c == KeyEvent.VK_LEFT) {
            board.moveLeft();
            board.printBoard();
        }
        if (c == KeyEvent.VK_DOWN) {
            board.moveDown();
            board.printBoard();
        }
        if (c == KeyEvent.VK_RIGHT) {
            board.moveRight();
            board.printBoard();
        }
        if (c == KeyEvent.VK_UP) {
            board.turnCW();
            board.printBoard();
        }
        if (c == KeyEvent.VK_C) {
            board.turnCCW();
            board.printBoard();
        }
        if (c == KeyEvent.VK_SPACE) {
            board.drop();
            board.printBoard();
        }
        if (!board.possibleDown) {
            board.createPento();
            board.checkAndPlace();
            board.printBoard();
        }

    }

    /*
     * (non-Javadoc)
     * 
     * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
     */
    public void keyTyped(KeyEvent e) {
        // System.out.println ( "Key Pressed" ) ;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
     */
    public void keyReleased(KeyEvent e) {
        // System.out.println( "no Action when releasing" ) ;
    }

}